package com.wolfsea.viewpager2demo.ui.define
import android.view.View
import androidx.viewpager2.widget.ViewPager2

/**
 *@desc   PageTransformer
 *@author liuliheng
 *@time 2022/3/20  18:26
 **/
class DIYPageTransformer : ViewPager2.PageTransformer {

    override fun transformPage(page: View, position: Float) {
        val diyConstraintLayout = page as DIYConstraintLayout
        //倾斜角度
        val tiltDegree = 34
        val rotateYDegree = position.times(tiltDegree)
        diyConstraintLayout.updateRotateY(rotateYDegree)
        if (position > 0) {
            diyConstraintLayout.updateIsLeftRotate(true)
        } else {
            diyConstraintLayout.updateIsLeftRotate(false)
        }
    }
}